Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #13309: return correct real value from var, varm, etc of complex arrays #13348

Merged
merged 1 commit into from
Sep 29, 2015

Conversation

stevengj
Copy link
Member

This fixes issue #13309:

  • var(iterable) and varm(iterable, mean) were giving the wrong values for complex arrays
  • var(z) and varm(z,mean), cov(z) etc. were giving the correct values, but were suboptimal because they often returned a complex result even though the variance is (by definition) purely real
  • varm was type unstable (sometimes returning real, sometimes returning complex results, depending on the length of the complex array)
  • cor(z) was going to a lot of effort just to return 1. Also, there seems no point in returning a complex or floating-point 1 when one(real(T)) will do for an array of T.

@stevengj stevengj added the maths Mathematical functions label Sep 28, 2015
@andreasnoack
Copy link
Member

LGTM. There shouldn't be any problems in backporting this, right?

@stevengj
Copy link
Member Author

No, please backport.

stevengj added a commit that referenced this pull request Sep 29, 2015
fix #13309: return correct real value from var, varm, etc of complex arrays
@stevengj stevengj merged commit 6fa9326 into JuliaLang:master Sep 29, 2015
@stevengj stevengj deleted the zvar branch September 29, 2015 02:59
stevengj added a commit that referenced this pull request Sep 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maths Mathematical functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants